<template>
  <div class="collegeInit">
    <el-breadcrumb separator="/" class="breadcrumb-bottom">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统管理</el-breadcrumb-item>
      <el-breadcrumb-item>学院初始化</el-breadcrumb-item>
    </el-breadcrumb>
    <el-form ref="form" :model="form" label-width="80px" class="fixed-form">
      <el-form-item label="学院编号">
        <el-input v-model="form.collegeID"></el-input>
      </el-form-item>
      <el-form-item label="学院名称">
        <el-input v-model="form.collegeName"></el-input>
      </el-form-item>
      <el-form-item label="学院简称">
        <el-input v-model="form.collegeShortName"></el-input>
      </el-form-item>
      <el-form-item label="学院院长">
        <el-input v-model="form.collegePresident"></el-input>
      </el-form-item>
      <el-form-item label="副院长">
        <el-input v-model="form.collegePresidentF"></el-input>
      </el-form-item>
      <el-form-item label="学院简介">
        <el-input type="textarea" v-model="form.collegeIntroduction"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="save">立即创建</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<style>
</style>
<script>
  export default{
    name: 'collegeInit',
    data(){
      return {
        form: {
          collegeID: '',
          collegeName: '',
          collegeShortName: '',
          collegePresident: '',
          collegePresidentF: '',
          collegeIntroduction: ''
        }
      }
    },
    created () {
      this.res();
    },
    methods: {
      res() {
        this.$http.get(`http://localhost:8080/TeachingMIS/college/get`).then((res) => {
          // 响应成功回调
          console.log(res.body)
          if (res.body.college != null) {
            this.form = res.body.college;
          }
        }, (err) => {
          // 响应错误回调
          console.log("服务器异常！");
        })
      },
      save(){
        alert(this.form.collegeID);
        this.$http.post(`http://localhost:8080/TeachingMIS/college/save`, this.form).then((res) => {
          // 响应成功回调
          console.log(res.body)
          this.courseInfo = res.body.arrangeList;
        }, (err) => {
          // 响应错误回调
          console.log("服务器异常！");
        })
      }
    }
  }
</script>
